package com.alan.annotation.validation.test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

import com.alan.annotation.validation.constraints.NotBlank;
import com.alan.annotation.validation.constraints.Impl.NotBlankValidator;

public class Main {
	public static void main(String[] args) {
		Test test = new Test();
		test.tt="AA";
		Class clzz = test.getClass();
		Field[] fields = clzz.getDeclaredFields();
		for (Field field : fields) {
			System.out.println("filed="+field.getName());
			Annotation[]  anns = field.getAnnotations();
			field.setAccessible(true);//AccessibleTest类中的成员变量为private,故必须进行此操作  
			for (Annotation annotation : anns) {
				System.out.println("anno="+annotation.getClass());
				
				if(annotation instanceof NotBlank){
					System.out.println("============");
					NotBlank notBlank = (NotBlank) annotation;
					
				}
			}
		}
		
		
		
		/*Method[] methods = clzz.getDeclaredMethods();
		for (Method method : methods) {
			System.out.println("methodName="+method.getName());
			
			Class[] arr = method.getParameterTypes();
			for (Class class1 : arr) {
				System.out.println("class_name="+class1.getName());
				Annotation[]  anns =  class1.getAnnotations();
				for (Annotation annotation : anns) {
					System.out.println("anno="+annotation.getClass());
				}
			}
			Parameter[] para = method.getParameters();
			for (Parameter parameter : para) {
				Annotation[]  anns =  parameter.getAnnotations();
				for (Annotation annotation : anns) {
					System.out.println("anno="+annotation.getClass());
					if(annotation instanceof NotBlank){
						System.out.println("============");
						NotBlank notBlank = (NotBlank) annotation;
					}
				}
			}
			//System.out.println("---"+method.getGenericParameterTypes()[0].getClass().getName());
			//System.out.println("===="+method.getGenericParameterTypes()[0].getClass().getAnnotations()[0].getClass());
		}*/
	}
}
